<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Constructs the EvChild watcher object</title>
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-base.css" />
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-medium.css" />

 </head>
 <body class="docs"><div class="navbar navbar-fixed-top">
  <div class="navbar-inner clearfix">
    <ul class="nav" style="width: 100%">
      <li style="float: left;"><a href="class.evchild.html">« EvChild</a></li>
      <li style="float: right;"><a href="evchild.createstopped.html">EvChild::createStopped »</a></li>
    </ul>
  </div>
</div>
<div id="breadcrumbs" class="clearfix">
  <ul class="breadcrumbs-container">
    <li><a href="index.html">PHP Manual</a></li>
    <li><a href="class.evchild.html">EvChild</a></li>
    <li>Constructs the EvChild watcher object</li>
  </ul>
</div>
<div id="layout">
  <div id="layout-content"><div id="evchild.construct" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">EvChild::__construct</h1>
  <p class="verinfo">(PECL ev &gt;= 0.2.0)</p><p class="refpurpose"><span class="refname">EvChild::__construct</span> &mdash; <span class="dc-title">Constructs the EvChild watcher object</span></p>

 </div>
 <div class="refsect1 description" id="refsect1-evchild.construct-description">
  <h3 class="title">说明</h3>
  <div class="constructorsynopsis dc-description">
   <span class="modifier">public</span>
   <span class="methodname"><strong>EvChild::__construct</strong></span>(<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam">
    <span class="type">int</span>
     <code class="parameter">$pid</code>
   </span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam">
    <span class="type">bool</span>
     <code class="parameter">$trace</code>
   </span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam">
    <span class="type"><a href="language.types.callable.html" class="type callable">callable</a></span>
     <code class="parameter">$callback</code>
   </span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam">
    <span class="type"><a href="language.types.declarations.html#language.types.declarations.mixed" class="type mixed">mixed</a></span>
     <code class="parameter">$data</code>
    <span class="initializer"> = <strong><code>null</code></strong></span>
   </span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam">
    <span class="type">int</span>
     <code class="parameter">$priority</code>
    <span class="initializer"> = 0</span>
   </span><br>)</div>

  <p class="para rdfs-comment">
   Constructs the
   <span class="classname"><a href="class.evchild.html" class="classname">EvChild</a></span>
   watcher object.
  </p>
  <p class="para">
   Call the callback when a status change for process ID
   <code class="parameter">pid</code>
   (or any
   <em class="emphasis">PID</em>
   if
   <code class="parameter">pid</code>
   is
   <strong><code>0</code></strong>
   ) has been received(a status change happens when the process terminates or
   is killed, or, when
   <code class="parameter">trace</code>
   is <strong><code>true</code></strong>, additionally when it is stopped or continued). In other words,
   when the process receives a
   <strong><code>SIGCHLD</code></strong>
   ,
   <em class="emphasis">Ev</em>
   will fetch the outstanding exit/wait status for all changed/zombie children
   and call the callback.
  </p>
  <p class="para">
   It is valid to install a child watcher after an
   <span class="classname"><a href="class.evchild.html" class="classname">EvChild</a></span>
   has exited but before the event loop has started its next iteration. For
   example, first one calls
   <code class="literal">fork</code>
   , then the new child process might exit, and only then an
   <span class="classname"><a href="class.evchild.html" class="classname">EvChild</a></span>
   watcher is installed in the parent for the new
   <em class="emphasis">PID</em>
   .
  </p>
  <p class="para">
   You can access both exit/tracing status and
   <code class="parameter">pid</code>
   by using the
   <var class="varname">rstatus</var>
   and
   <var class="varname">rpid</var>
   properties of the watcher object.
  </p>
  <p class="para">
   The number of
   <em class="emphasis">PID</em>
   watchers per
   <em class="emphasis">PID</em>
   is unlimited. All of them will be called.
  </p>
  <p class="para">
   The
   <span class="methodname"><a href="evchild.createstopped.html" class="methodname">EvChild::createStopped()</a></span>
   method doesn&#039;t start(activate) the newly created watcher.
  </p>
 </div>

 <div class="refsect1 parameters" id="refsect1-evchild.construct-parameters">
  <h3 class="title">参数</h3>
  <dl>
   
    <dt>

     <code class="parameter">pid</code>
    </dt>

    <dd>

     <p class="para">
      Wait for status changes of process PID(or any process if PID is
      specified as
      <strong><code>0</code></strong>
      ).
     </p>
    </dd>

   
   
    <dt>

     <code class="parameter">trace</code>
    </dt>

    <dd>

     <p class="para">
      If <strong><code>false</code></strong>, only activate the watcher when the process terminates.
      Otherwise(<strong><code>true</code></strong>) additionally activate the watcher when the process is
      stopped or continued.
     </p>
    </dd>

   
   
    <dt>

     <code class="parameter">callback</code>
    </dt>

    <dd>

     <p class="para">
      See
      <a href="ev.watcher-callbacks.html" class="link">Watcher callbacks</a>
      .
     </p>
    </dd>

   
   
    <dt>

     <code class="parameter">data</code>
    </dt>

    <dd>

     <p class="para">
      Custom data associated with the watcher.
     </p>
    </dd>

   
   
    <dt>

     <code class="parameter">priority</code>
    </dt>

    <dd>

     <p class="para">
      <a href="class.ev.html#ev.constants.watcher-pri" class="link">Watcher priority</a>
     </p>
    </dd>

   
  </dl>

 </div>


 <div class="refsect1 seealso" id="refsect1-evchild.construct-seealso">
  <h3 class="title">参见</h3>
  <ul class="simplelist">
   <li class="member">
    <span class="methodname"><a href="evloop.child.html" class="methodname" rel="rdfs-seeAlso">EvLoop::child()</a> - Creates EvChild object associated with the current event loop</span>
   </li>
  </ul>
 </div>

</div></div></div></body></html>